package com.android.broadcast;

import android.app.Activity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;

public class SendBroadcastActivity extends Activity implements OnClickListener{
	private final String RECEIVER_INTENT_ACTION = "com.android.project.broadcast";
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button sendBtn = new Button(this);
        sendBtn.setOnClickListener(this);
        sendBtn.setId(11);
        sendBtn.setText("send broadcast");
        LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        addContentView(sendBtn, params);
    }

	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v.getId() == 11) {
			Intent intent = new Intent(RECEIVER_INTENT_ACTION);
			sendBroadcast(intent);
//			sendBroadcast(intent, "com.android.broadcast.test");
			Log.i("com","send broadcast success!!");
		}
	}
    
}